//
//  CC_CircularImage_Label_CollectionViewCell.m
//  HimalayaMountain
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CC_CircularImage_Label_CollectionViewCell.h"
#import "CCBaceHeaderImageView.h"
#import "CCBaseMainTitleLabel.h"
#import "CC_Classify_Model.h"

@interface CC_CircularImage_Label_CollectionViewCell ()

@property(nonatomic, retain) CCBaceHeaderImageView *circularImageView;
@property(nonatomic, retain) CCBaseMainTitleLabel *titleLabel;

@end



@implementation CC_CircularImage_Label_CollectionViewCell

- (void)dealloc
{
    [_classifyModel release];
    [_circularImageView release];
    [_titleLabel release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        self.circularImageView = [[CCBaceHeaderImageView alloc]init];
        self.circularImageView.layer.cornerRadius = (SCREENHEIGHT / 7 - 4 * SPACED) / 2;
        self.circularImageView.clipsToBounds = YES;
        
//        self.circularImageView.backgroundColor = [UIColor greenColor];
        
        [self.contentView addSubview:_circularImageView];
        [_circularImageView release];
        
        self.titleLabel = [[CCBaseMainTitleLabel alloc]init];
        
//        self.titleLabel.backgroundColor = [UIColor yellowColor];
        self.titleLabel.textAlignment = 1;
        
        [self.contentView addSubview:_titleLabel];
        [_titleLabel release];
        
    }
    return self;
}

-(void)layoutSubviews{
    
//      flowLayout.itemSize = CGSizeMake(SCREENWIDTH / 5,SCREENHEIGHT / 7 - 2 * SPACED);
    self.circularImageView.frame =CGRectMake(0, 0, SCREENWIDTH / 5.5, SCREENHEIGHT / 7 - 4 * SPACED);
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.circularImageView.mas_bottom).offset(SPACED / 4);
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
        make.right.equalTo(self.contentView.mas_right).offset(0);
        
    }];
    
}

-(void)setClassifyModel:(CC_Classify_Model *)classifyModel{
    if (_classifyModel != classifyModel) {
        [_classifyModel release];
        _classifyModel = [classifyModel retain];
    }
    
    [self.circularImageView setImageWithURL:[NSURL URLWithString:classifyModel.coverPath] placeholderImage:PLACEHOLDERIMAGE];
    self.titleLabel.text = classifyModel.title;
    
}




@end
